package ysq.xyg.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import ysq.xyg.dao.FlowDescDao;
import ysq.xyg.model.BaseMenu;
import ysq.xyg.model.FlowDesc;
import ysq.xyg.service.FlowDescService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 流量
 *
 * @author congcong tao
 * @date 2018/9/5 13:38
 */
@Service("flowDescService")
public class FlowDescServiceImpl extends BaseServiceImpl<FlowDesc> implements FlowDescService {

    @Resource
    private FlowDescDao flowDescDao;
    @Autowired
    public void setFlowDescDao(FlowDescDao flowDescDao) {
        this.baseDao = flowDescDao;
    }

    @Override
    public PageInfo<FlowDesc> pageInfo(FlowDesc flowDesc, int pageSize, int pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        Example example = new Example(BaseMenu.class);
        Example.Criteria criteria = example.createCriteria();
        if(StringUtil.isNotEmpty(flowDesc.getTitle())){
            criteria.andLike("title","%" + flowDesc.getTitle() + "%");
        }
        List<FlowDesc> list = flowDescDao.selectByExample(example);
        return new PageInfo<FlowDesc>(list);
    }
}
